package tongwentongshu.com.app.adapter;


import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import tongwentongshu.com.app.R;
import tongwentongshu.com.app.bean.BookSearchBean;
import tongwentongshu.com.app.bean.MyShareBean;
import tongwentongshu.com.app.utils.GlideUtil;

/**
 * 文 件 名: MainBooksAdapter
 * 创 建 人: Allen
 * 创建日期: 16/12/24 19:55
 * 邮   箱: AllenCoder@126.com
 * 修改时间：
 * 修改备注：
 */
public class SearchAdapter extends BaseQuickAdapter<BookSearchBean.DataBean, BaseViewHolder> {
    private Context mContext;

    public SearchAdapter(Context mContext, List<BookSearchBean.DataBean> list) {
        super(R.layout.view_search_result, list);
        this.mContext = mContext;
    }

    @Override
    protected void convert(BaseViewHolder helper, BookSearchBean.DataBean item) {
        helper.setText(R.id.tv_book_name, item.getBook_name());
        helper.setText(R.id.tv_book_distance, item.getDistance());
        helper.setText(R.id.tv_book_des, item.getBookdesc());
        helper.setText(R.id.tv_book_type, "【" + item.getBooktype() + "】");
        TextView status = (TextView) helper.getView(R.id.tv_book_status);
        switch (item.getBook_status()) {
            case "3":
                status.setText("空闲");
                status.setTextColor(mContext.getResources().getColor(R.color.reading_));
//                helper.setImageResource(R.id.iv_book_status, R.drawable.status_reading);
                break;
            case "2":
                status.setText("在读");
                status.setTextColor(mContext.getResources().getColor(R.color.reading_));
//                helper.setImageResource(R.id.iv_book_status, R.drawable.status_to_reading);
                break;
            case "1":
                status.setText("被预约");
                status.setTextColor(mContext.getResources().getColor(R.color.reading_));
//                helper.setImageResource(R.id.iv_book_status, R.drawable.status_time);
                break;
            default:
                break;
        }
        GlideUtil.setImage1(mContext, item.getBookpicurl(), R.drawable.default_graph, R.drawable.default_graph, (ImageView) helper.getView(R.id.iv_book_image));
    }


}
